/**
 * 3
 *  
 * @Author : roryrywang
 * @DateTime : 24-9-7 下午3:55
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

void dfs(int x, int y, vector<vector<char>> &g, vector<vector<int>> &f, int &tmp) {
    f[x][y] = 1;
    tmp++;
    for (int k = 0; k < 4; ++k) {
        int xx = x + dx[k];
        int yy = y + dy[k];
        if (xx >= 0 && xx < f.size() && yy >= 0 && yy < f[0].size() && g[xx][yy] == '.' && f[xx][yy] == -1) {
            dfs(xx, yy, g, f, tmp);
        }
    }
}

void dfs2(int x, int y, vector<vector<char>> &g) {
    g[x][y] = '#';
    for (int k = 0; k < 4; ++k) {
        int xx = x + dx[k];
        int yy = y + dy[k];
        if (xx >= 0 && xx < g.size() && yy >= 0 && yy < g[0].size() && g[xx][yy] == '.') {
            dfs2(xx, yy, g);
        }
    }
}

void dfs3(int x, int y, vector<vector<char>> &g, vector<vector<int>> &f, int &tmp) {
    f[x][y] = 1;
    tmp++;
    for (int k = 0; k < 4; ++k) {
        int xx = x + dx[k];
        int yy = y + dy[k];
        if (xx >= 0 && xx < f.size() && yy >= 0 && yy < f[0].size() && g[xx][yy] == '#' && f[xx][yy] == -1) {
            dfs3(xx, yy, g, f, tmp);
        }
    }
}

int main() {
    int m, n;
    cin >> m >> n;
    vector<vector<char>> g(m, vector<char>(n));
    vector<vector<int>> f(m, vector<int>(n));

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> g[i][j];
            f[i][j] = -1;
        }
    }

    int tmpMax = 0;
    int tmpi = 0, tmpj = 0;

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            if (g[i][j] == '.' && f[i][j] == -1) {
                int tmp = 0;
                dfs(i, j, g, f, tmp);
                // cout<<i<<" "<<j<<" "<<tmp<<endl;
                if (tmpMax < tmp) {
                    tmpMax = tmp;
                    tmpi = i;
                    tmpj = j;
                }
            }
        }
    }

    dfs2(tmpi, tmpj, g);

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            f[i][j] = -1;
        }
    }

    int res = 0;

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            if (g[i][j] == '#' && f[i][j] == -1) {
                int tmp = 0;
                dfs3(i, j, g, f, tmp);
                // cout<<i<<" "<<j<<" "<<tmp<<endl;
                res = max(res, tmp);
            }
        }
    }

    // cout << res <<" "<< num;
    cout << res;

    return 0;
}